<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head> 
	<title>Videshop POS</title> 
	<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<f:view>
		<table border="0" cellpadding="0" cellspacing="10">
			<tr>
				<td colspan="2"><h1>Videoshop POS</h1></td>
			</tr>
			<tr>
				<td valign="top">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<!-- User section -->
								<f:subview id="userSection">
									<jsp:include page="user.jsp"/>
								</f:subview>
							</td>
						</tr>
						<tr>
							<td>
								<!-- Menu section -->
								<f:subview id="menuSection">
									<jsp:include page="menu.jsp"/>
								</f:subview>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" class="mainSection">
					<c:choose>
						<c:when test="${!empty userSection.staff && userSection.staff.seniorManager}">
							<h2>Titles</h2>
							
							<h:form>
								<h:panelGrid columns="4">
									<h:outputText styleClass="label" value="Title Id"/>
									<h:outputText styleClass="field" value="#{titleSection.selectedTitle.titleId}"/>
									<h:outputText styleClass="label" value="Name"/>
									<h:inputText styleClass="text200" value="#{titleSection.selectedTitle.titleName}"/>
									<h:outputText styleClass="label" value="Year"/>
									<h:inputText styleClass="text50" value="#{titleSection.selectedTitle.year}"/>
									<h:outputText styleClass="label" value="Classification"/>
									<h:selectOneListbox	styleClass="select100" size="1" value="#{titleSection.selectedTitleClassification}">
										<f:selectItems value="#{titleSection.classifications}"/>
									</h:selectOneListbox>
									<h:outputText styleClass="label" value="Category"/>
									<h:selectOneListbox	styleClass="select200" size="1" value="#{titleSection.selectedTitleCategory}">
										<f:selectItems value="#{titleSection.categories}"/>
									</h:selectOneListbox>
								</h:panelGrid>
								<h:inputTextarea value="#{titleSection.selectedTitle.description}" cols="50" rows="20"/>
								<br/>
								
								<h:dataTable 
												border="0" cellspacing="0" cellpadding="3"
												styleClass="dataTable"
												columnClasses="titleMediaTableMediumTypeColumn,titleMediaTableMaxRentalPeriodColumn,titleMediaTableRentalRateColumn,titleMediaTablePenaltyRateColumn"
												value="#{titleSection.selectedTitle.media}"
												var="medium"
								>
									<h:column headerClass="titleMediaTableMediumTypeColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Format</f:verbatim>
										</f:facet>
										<h:graphicImage url="#{medium.mediumType.iconUrl}" height="60px"/>
									</h:column>
									<h:column headerClass="titleMediaTableMaxRentalPeriodColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Max rental period</f:verbatim>
										</f:facet>
										<h:inputText styleClass="textNumber" value="#{medium.maxRentalPeriod}">
											<f:convertNumber pattern="0"/>
										</h:inputText>
									</h:column>
									<h:column headerClass="titleMediaTableRentalRateColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Rental rate</f:verbatim>
										</f:facet>
										<f:verbatim escape="true">$</f:verbatim>
										<h:inputText styleClass="textNumber" value="#{medium.rentalRate}">
											<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
										</h:inputText>
									</h:column>
									<h:column headerClass="titleMediaTablePenaltyRateColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Penalty rate</f:verbatim>
										</f:facet>
										<f:verbatim escape="true">$</f:verbatim>
										<h:inputText styleClass="textNumber" value="#{medium.penaltyRate}">
											<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
										</h:inputText>
									</h:column>
								</h:dataTable>
								<br/>
								<h:commandLink styleClass="button" action="#{titleSection.saveTitle}" value="Save"/>
							</h:form>
							<h:form>
								<h:commandLink styleClass="moreButton" action="browse" value="Back"/>
							</h:form>
						</c:when>
						<c:otherwise>
							Please login first
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
	</f:view>
</html>